import request from '@/utils/request'

// 获取合同管理数据
export function getContractData(status, perPage, page) {
  const data = {
    status, perPage, page
  }
  return request({
    url: 'api/v2/backend/market/contract/index',
    method: 'post',
    data
  })
}

// 续签之前先获取详情
export function getContractDetails(id) {
  const data = {
    id
  }
  return request({
    url: 'api/v3/backend/market/contract/show',
    method: 'post',
    data
  })
}

// 保存 新增 或者 续签 合同
export function contractAddSave(model) {
  const data = model
  return request({
    url: 'api/v3/backend/market/contract/add',
    method: 'post',
    data
  })
}

// 提交合同
export function submit(renewContractId, signDate, months, dueTime, businessId, businessName, stallName, contractAmount, contractNumber, contractPhoto) {
  const data = {
    renewContractId, signDate, months, dueTime, businessId, businessName, stallName, contractAmount, contractNumber, contractPhoto
  }
  return request({
    url: 'api/v1/backend/market/contract/add',
    method: 'post',
    data
  })
}

// 点击合同解除
export function contractRemove(id, status) {
  const data = {
    id, status
  }
  return request({
    url: 'api/v2/backend/market/contract/change/status',
    method: 'post',
    data
  })
}

// 点击合同续签
export function contractShow(id) {
  const data = {
    id
  }
  return request({
    url: 'api/v1/backend/market/contract/show',
    method: 'post',
    data
  })
}

// 获取 收费项目 类型
export function getPaymentType(searchName) {
  const data = {
    searchName
  }
  return request({
    url: 'api/v2/backend/market/contract/choice_pay_service',
    method: 'post',
    data
  })
}
